<script type="text/javascript" src="__JS__/swfupload/swfupload.js"></script>
<script type="text/javascript" src="__JS__/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="__JS__/swfupload/handlers.js"></script>

<script type="text/javascript">
var swfu;
var appdomain = '<php>echo APP_DOMAIN</php>';
var inter;
window.onload = function() {
    var settings = {
        flash_url : "__JS__/swfupload/swfupload.swf",
        upload_url: "{:U('Admin/Goods/uploadImg')}",  // Relative to the SWF file
        post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
        file_size_limit : "5 MB",
        file_types : "*.jpg;*.jpeg;*.gif;*.png;*.bmp",
        file_types_description : "All Files",
        file_upload_limit : 200,
        file_queue_limit : 4,
        custom_settings : {
            progressTarget : "fsUploadProgress",
            cancelButtonId : "btnCancel"
        },
        debug: false,

        // Button settings
        button_image_url: "__JS__/swfupload/bg.png",  // Relative to the Flash file
        button_width: "65",
        button_height: "22",
        button_placeholder_id: "spanButtonPlaceHolder",
        //button_text: '选择图片',
        //button_text_style: ".theFont { font-size: 16; }",
        //button_text_left_padding: 12,
        //button_text_top_padding: 3,
        button_cursor: SWFUpload.CURSOR.HAND,
        
        // The event handler functions are defined in handlers.js
        file_queued_handler : fileQueued,
        file_queue_error_handler : fileQueueError,
        upload_start_handler : uploadStart,
        upload_progress_handler : uploadProgress,
        upload_error_handler : uploadError,
        upload_success_handler : uploadSuccess
    };
    swfu = new SWFUpload(settings);
 };

 function setMallUpload(){
    if(checkPic())
    {
        inter = setInterval("ul()",1000);
    }
 }
 function ul(){
    swfu.startUpload();
 }
 function checkPic(){
    var liLength = $("#picul li").length;
    var re = false;
    if(liLength>4)
    {
        re = false
    }else{
        re = 4-liLength;
    }
    if(re==false){
        //alert("最多只能上传4张图片，请先删除至少一张图片");
        $("#picNotice").html("已经上传了4张图片了，不能继续上传了");
    }
    return re;
}  //用来判断是否有空余的img标签供上传

function addImg(pic){
    // var li = checkPic();
    // if(li){
        var absPic = appdomain+pic;
        var img_li = "<li><img src='"+absPic+"' width='100px' height='100px'><br/><a href='' onclick='delPic(this);return false;' title='删除图片'>删除</a><input type='hidden' name='pic[]' value='"+pic+"'></li>"
        $('#picul').append(img_li);
    //}
}

function delPic(obj){
    var liObj = $(obj).parent();
    liObj.remove();
}
</script>
<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="#">常用操作</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="#">商品管理</a><span class="crumb-step">&gt;</span><span>新增商品</span></div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form action="{:U('Goods/set')}" method="post" id="myform" name="myform" enctype="multipart/form-data">
                <input type="hidden" name="id" value="{$data.id}">
                <table class="insert-tab" width="100%">
                    <tbody>
                    
                    <tr>
                        <th width="120"><i class="require-red">*</i>标题：</th>
                        <td>
                            <input class="common-text required" id="title" name="title" size="50" value="{$data.title}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th width="120"><i class="require-red">*</i>产品型号：</th>
                        <td>
                            <input class="common-text required" id="item" name="item" size="50" value="{$data.item}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th width="120"><i class="require-red">*</i>卡券类型：</th>
                        <td>
                            {:frm_out_put($sortarr,'sort','option',$data['sort'])}
                        </td>
                    </tr>
                    <tr>
                        <th width="120"><i class="require-red">*</i>产品分类：</th>
                        <td>
                            {:frm_out_put($categray,'categray','option',$data['categray'])}
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>市场价：</th>
                        <td><input class="common-text" name="price" size="30" type="text" value="{$data.price}"></td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>联通商城价：</th>
                        <td><input class="common-text" name="saleprice" size="30" type="text" value="{$data.saleprice}"></td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>产品图片：</th>
                        <td>
                        <span  id="spanButtonPlaceHolder"></span>
                        <span class="fontGray9">( 图片大小不要超过200K,最佳尺寸640*490。您可以一次选择多张图片 )</span><span id="fsUploadProgress" style="width:100px"></span><br>
                        <span class="spacing15"><button type="button" class="btn btn-primary btn2"  onclick="setMallUpload()">上传</button></span><span class="spacing15" id="picNotice">最多只能上传4张图片</span>
                        <br>
                        <ul class="clear" id="picul">    
                            <php>
                                if($data['img']){
                                    $imglist = json_decode($data['img'],true);
                                    foreach($imglist as $v){
                                        echo "<li><img src='".getImgPath($v)."' width='100px' height='100px'><br/><a href='' onclick='delPic(this);return false;' title='删除图片'>删除</a><input type='hidden' name='pic[]' value='".$v."'></li>";
                                    }
                                    
                                }
                            </php>
                        </ul>
                        </td>
                    </tr>

                    <tr style="line-height:20px;">
                        <th>产品详情：</th>
                        <td>
<!--                         <textarea name="content" class="common-textarea" id="content" cols="30" style="width: 80%;" rows="10"></textarea>
 -->                        <script id="content" name="content" type="text/plain" style="width:720px">{:htmlspecialchars_decode($data[content])}</script>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>截止日期：</th>
                        <td>
                            <input class="common-text" name="deadline" size="30" type="text" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59'})">
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody></table>
            </form>

        </div>
    </div>

</div>
<script language="javascript" type="text/javascript" src="__JS__/calendar/WdatePicker.js"></script>
<script type="text/javascript"  src="__JS__/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__JS__/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
var editor = UE.getEditor('content',{  
    //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个  
    toolbars:[['fullscreen', 'source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|','customstyle', 'paragraph', 'fontfamily', 'fontsize', '|','directionalityltr', 'directionalityrtl', 'indent', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|','insertimage','preview',]],  
    //focus时自动清空初始化时的内容  
    //autoClearinitialContent:true,  
    //关闭字数统计  
    wordCount:false,  
    //关闭elementPath  
    //elementPathEnabled:true,  
    //默认的编辑区域高度  
    initialFrameHeight:300,
    imageUrl:"{:U('Admin/Goods/editorUpload')}",
    //更多其他参数，请参考ueditor.config.js中的配置项  
});
</script>